package com.zyl.Ecs.realtime.task;

import com.zyl.Ecs.realtime.service.TableService;
import lombok.RequiredArgsConstructor;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @version v1.0
 * @ProjectName: Ecs
 * @Package: com.zyl.Ecs.realtime.task
 * @ClassName: CreateTableTask
 * @Description TODO 每月最后一天23:30~23:39尝试创建下个月表格，每2分钟尝试1次
 * @Author 翟玉龙
 * @Date 2024/12/6-13:32
 */
@Component
@EnableScheduling
@RequiredArgsConstructor
public class CreateTableTask {

    private final TableService tableService;

    /**
     * cron域语法：秒 分 时 日 月 周 [年]
     * 异步方式
     */
    @Async
    @Scheduled(cron = "0 30-49/2 23 L * *", zone = "Asia/Shanghai")
    protected void configureTasks() {
        tableService.createNextMonthTable();
    }

}